﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Imagine;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Graphics;


namespace Carmack
{
    class MenuScreen : GameScreen
    {
        AvailableNetworkSessionCollection availSession;
       public override bool Init(object extraData)   //Any data that needs to be passed from One State to another
       {
           return true;
       }     
       public override bool Draw(GameTime gameTime, SpriteBatch _spritebatch)
       {
           Engine.Instance().GraphicsDevice.Clear(Color.Red);
           return true;
       }
       public override bool Update(GameTime gameTime)
       {
           if(TheInputManager.Instance().IsKeyDown(Keys.D1))
               TheScreenManager.Instance().SetScreen( (int)eGameScreens.TestScreen, (int)eScreenState.DEAD, null );
           if (TheInputManager.Instance().IsKeyDown(Keys.D2))
           {
               Refresh();
               if (availSession.Count > 0)
               {
                    NetworkManager.Instance().Session = NetworkSession.Join(availSession[0]);
                    NetworkManager.Instance().HookEventHandlers( NetworkManager.Instance().Session );
                    TheScreenManager.Instance().SetScreen( (int)eGameScreens.GamePlayScreen, (int)eScreenState.DEAD, null );
               }                                    
           }
               
           return true;
       }
       public override bool Release()   { return true; } 

       void Refresh()
       {
           availSession = NetworkSession.Find(NetworkSessionType.SystemLink, 1/*1-4*/, null);
       }
        
    }
}